<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>样式 | minigame-canvas-engine</title>
    <meta name="description" content="轻量级canvas渲染引擎">
    <meta name="generator" content="VuePress 1.3.1">
    <meta name="robots" content="all">
  <meta name="author" content="yuanzm">
  <meta name="keywords" content="minigame-canvans-engine, minigame, canvas, engine, game engine">
    
    <link rel="preload" href="/minigame-canvas-engine/assets/css/0.styles.cc9e188e.css" as="style"><link rel="preload" href="/minigame-canvas-engine/assets/js/app.34da408a.js" as="script"><link rel="preload" href="/minigame-canvas-engine/assets/js/2.b58d2eb8.js" as="script"><link rel="preload" href="/minigame-canvas-engine/assets/js/8.5202cd3c.js" as="script"><link rel="prefetch" href="/minigame-canvas-engine/assets/js/10.525d02f5.js"><link rel="prefetch" href="/minigame-canvas-engine/assets/js/3.65046f77.js"><link rel="prefetch" href="/minigame-canvas-engine/assets/js/4.e50764d8.js"><link rel="prefetch" href="/minigame-canvas-engine/assets/js/5.aa96439f.js"><link rel="prefetch" href="/minigame-canvas-engine/assets/js/6.8bafe2e6.js"><link rel="prefetch" href="/minigame-canvas-engine/assets/js/7.6ddd2960.js"><link rel="prefetch" href="/minigame-canvas-engine/assets/js/9.b0c2371a.js">
    <link rel="stylesheet" href="/minigame-canvas-engine/assets/css/0.styles.cc9e188e.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/minigame-canvas-engine/" class="home-link router-link-active"><!----> <span class="site-name">minigame-canvas-engine</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"> <a href="https://github.com/wechat-miniprogram/minigame-canvas-engine" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"> <a href="https://github.com/wechat-miniprogram/minigame-canvas-engine" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></nav>  <ul class="sidebar-links"><li><a href="/minigame-canvas-engine/" class="sidebar-link">概览</a></li><li><section class="sidebar-group depth-0"><a href="/minigame-canvas-engine/api/guide" class="sidebar-heading clickable open"><span>文档</span> <!----></a> <ul class="sidebar-links sidebar-group-items"><li><a href="/minigame-canvas-engine/api/guide.html" class="sidebar-link">快速入门</a></li><li><a href="/minigame-canvas-engine/api/api.html" class="sidebar-link">API</a></li><li><a href="/minigame-canvas-engine/api/tags.html" class="sidebar-link">标签</a></li><li><a href="/minigame-canvas-engine/api/style.html" class="active sidebar-link">样式</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/minigame-canvas-engine/api/style.html#布局" class="sidebar-link">布局</a></li><li class="sidebar-sub-header"><a href="/minigame-canvas-engine/api/style.html#文本" class="sidebar-link">文本</a></li><li class="sidebar-sub-header"><a href="/minigame-canvas-engine/api/style.html#容器" class="sidebar-link">容器</a></li><li class="sidebar-sub-header"><a href="/minigame-canvas-engine/api/style.html#边框" class="sidebar-link">边框</a></li></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="样式"><a href="#样式" class="header-anchor">#</a> 样式</h1> <h2 id="布局"><a href="#布局" class="header-anchor">#</a> 布局</h2> <table><thead><tr><th>属性名</th> <th>支持的值或类型</th> <th>默认值</th></tr></thead> <tbody><tr><td>width</td> <td>number</td> <td>0</td></tr> <tr><td>height</td> <td>number</td> <td>0</td></tr> <tr><td>position</td> <td>relative, absolute</td> <td>relative</td></tr> <tr><td>left</td> <td>number</td> <td>0</td></tr> <tr><td>top</td> <td>number</td> <td>0</td></tr> <tr><td>right</td> <td>number</td> <td>0</td></tr> <tr><td>bottom</td> <td>number</td> <td>0</td></tr> <tr><td>margin</td> <td>number</td> <td>0</td></tr> <tr><td>marginLeft</td> <td>number</td> <td>0</td></tr> <tr><td>marginRight</td> <td>number</td> <td>0</td></tr> <tr><td>marginTop</td> <td>number</td> <td>0</td></tr> <tr><td>marginBottom</td> <td>number</td> <td>0</td></tr> <tr><td>padding</td> <td>number</td> <td>0</td></tr> <tr><td>paddingLeft</td> <td>number</td> <td>0</td></tr> <tr><td>paddingRight</td> <td>number</td> <td>0</td></tr> <tr><td>paddingTop</td> <td>number</td> <td>0</td></tr> <tr><td>paddingBottom</td> <td>number</td> <td>0</td></tr> <tr><td>borderWidth</td> <td>number</td> <td>0</td></tr> <tr><td>borderRadius</td> <td>number</td> <td>0</td></tr> <tr><td>flexDirection</td> <td>column, row</td> <td>row</td></tr> <tr><td>flexShrink</td> <td>number</td> <td>1</td></tr> <tr><td>flexGrow</td> <td>number</td> <td></td></tr> <tr><td>flexWrap</td> <td>wrap, nowrap</td> <td>nowrap</td></tr> <tr><td>justifyContent</td> <td>flex-start, center, flex-end, space-between, space-around</td> <td>flex-start</td></tr> <tr><td>alignItems, alignSelf</td> <td>flex-start, center, flex-end, stretch</td> <td>flex-start</td></tr></tbody></table> <h2 id="文本"><a href="#文本" class="header-anchor">#</a> 文本</h2> <table><thead><tr><th>属性名</th> <th>支持的值或类型</th> <th>默认值</th></tr></thead> <tbody><tr><td>fontSize</td> <td>number</td> <td>14</td></tr> <tr><td>lineHeight</td> <td>number / string</td> <td>'1.4em'</td></tr> <tr><td>textAlign</td> <td>left, center, right</td> <td>left</td></tr> <tr><td>verticalAlign</td> <td>top, middle, bottom</td> <td>top</td></tr> <tr><td>color</td> <td>string</td> <td>#000000</td></tr> <tr><td>backgroundColor</td> <td>string</td> <td>transparent</td></tr> <tr><td>textOverflow</td> <td>ellipsis, clip</td> <td>默认为空，出于性能考虑，只有显式指定textOverflow属性的时候才会对文字进行截断处理</td></tr></tbody></table> <h2 id="容器"><a href="#容器" class="header-anchor">#</a> 容器</h2> <table><thead><tr><th>属性</th> <th>类型</th> <th>默认值</th> <th>说明</th></tr></thead> <tbody><tr><td>backgroundColor</td> <td>string</td> <td></td> <td>背景的颜色，支持 6 位 16 进制、8 位 16 进制、rgb、rgba 四种格式的颜色</td></tr></tbody></table> <h2 id="边框"><a href="#边框" class="header-anchor">#</a> 边框</h2> <table><thead><tr><th>属性</th> <th>类型</th> <th>默认值</th> <th>说明</th></tr></thead> <tbody><tr><td>borderRadius</td> <td>number</td> <td></td> <td>边框圆角</td></tr> <tr><td>borderColor</td> <td>string</td> <td></td> <td>边框颜色，支持 6 位 16 进制、8 位 16 进制、rgb、rgba 四种格式的颜色</td></tr></tbody></table></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/wechat-miniprogram/minigame-canvas-engine/edit/master/api/style.md" target="_blank" rel="noopener noreferrer">在 GitHub 上编辑此页</a> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">3/15/2020, 8:10:26 PM</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/minigame-canvas-engine/api/tags.html" class="prev">
        标签
      </a></span> <!----></p></div> </main></div><div class="global-ui"></div></div>
    <script src="/minigame-canvas-engine/assets/js/app.34da408a.js" defer></script><script src="/minigame-canvas-engine/assets/js/2.b58d2eb8.js" defer></script><script src="/minigame-canvas-engine/assets/js/8.5202cd3c.js" defer></script>
  </body>
</html>
